package com.demo.controller;

import com.demo.common.Result;
import com.demo.pojo.dto.AdvancedScheduleRequestDTO;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
 * 排课演示控制器
 */
@RestController
@RequestMapping("/schedule-demo")
@CrossOrigin
public class ScheduleDemoController {
    
    /**
     * 演示1：基本排课
     */
    @GetMapping("/demo1")
    public Result<AdvancedScheduleRequestDTO> demo1() {
        AdvancedScheduleRequestDTO request = new AdvancedScheduleRequestDTO();
        request.setSemester("advanced");
        request.setMaxPeriodsPerWeek(12);
        request.setMaxPeriodsPerDay(8);
        request.setEvenDistribution(true);
        request.setAvoidTeacherConflict(true);
        request.setAvoidClassroomConflict(true);
        request.setPriority(3);
        request.setRemark("基本排课演示");
        
        return Result.success(request);
    }
    
    /**
     * 演示2：选择特定班级排课
     */
    @GetMapping("/demo2")
    public Result<AdvancedScheduleRequestDTO> demo2() {
        AdvancedScheduleRequestDTO request = new AdvancedScheduleRequestDTO();
        request.setSemester("advanced");
        request.setSelectedClazzIds(Arrays.asList(1L, 2L, 3L));
        request.setMaxPeriodsPerWeek(10);
        request.setMaxPeriodsPerDay(6);
        request.setEvenDistribution(true);
        request.setAvoidTeacherConflict(true);
        request.setAvoidClassroomConflict(true);
        request.setPriority(4);
        request.setRemark("选择特定班级排课");
        
        return Result.success(request);
    }
    
    /**
     * 演示3：选择特定课程排课
     */
    @GetMapping("/demo3")
    public Result<AdvancedScheduleRequestDTO> demo3() {
        AdvancedScheduleRequestDTO request = new AdvancedScheduleRequestDTO();
        request.setSemester("advanced");
        request.setSelectedCourseIds(Arrays.asList(1L, 2L, 3L, 4L, 5L));
        request.setMaxPeriodsPerWeek(8);
        request.setMaxPeriodsPerDay(4);
        request.setEvenDistribution(true);
        request.setAvoidTeacherConflict(true);
        request.setAvoidClassroomConflict(true);
        request.setPriority(5);
        request.setRemark("选择特定课程排课");
        
        return Result.success(request);
    }
    
    /**
     * 演示4：严格课时限制排课
     */
    @GetMapping("/demo4")
    public Result<AdvancedScheduleRequestDTO> demo4() {
        AdvancedScheduleRequestDTO request = new AdvancedScheduleRequestDTO();
        request.setSemester("advanced");
        request.setMaxPeriodsPerWeek(6);
        request.setMaxPeriodsPerDay(2);
        request.setEvenDistribution(true);
        request.setAvoidTeacherConflict(true);
        request.setAvoidClassroomConflict(true);
        request.setPriority(5);
        request.setRemark("严格课时限制排课");
        
        return Result.success(request);
    }
    
    /**
     * 演示5：宽松排课
     */
    @GetMapping("/demo5")
    public Result<AdvancedScheduleRequestDTO> demo5() {
        AdvancedScheduleRequestDTO request = new AdvancedScheduleRequestDTO();
        request.setSemester("advanced");
        request.setMaxPeriodsPerWeek(20);
        request.setMaxPeriodsPerDay(10);
        request.setEvenDistribution(false);
        request.setAvoidTeacherConflict(false);
        request.setAvoidClassroomConflict(false);
        request.setPriority(1);
        request.setRemark("宽松排课");
        
        return Result.success(request);
    }
    
    /**
     * 获取所有演示配置
     */
    @GetMapping("/all-demos")
    public Result<String> getAllDemos() {
        StringBuilder demos = new StringBuilder();
        demos.append("排课演示配置：\n\n");
        
        demos.append("1. 基本排课演示\n");
        demos.append("   GET /schedule-demo/demo1\n");
        demos.append("   特点：使用默认参数，适合大多数情况\n\n");
        
        demos.append("2. 选择特定班级排课\n");
        demos.append("   GET /schedule-demo/demo2\n");
        demos.append("   特点：只对指定班级排课，每周最多10节，每天最多6节\n\n");
        
        demos.append("3. 选择特定课程排课\n");
        demos.append("   GET /schedule-demo/demo3\n");
        demos.append("   特点：只对指定课程排课，每周最多8节，每天最多4节\n\n");
        
        demos.append("4. 严格课时限制排课\n");
        demos.append("   GET /schedule-demo/demo4\n");
        demos.append("   特点：严格的课时限制，每周最多6节，每天最多2节\n\n");
        
        demos.append("5. 宽松排课\n");
        demos.append("   GET /schedule-demo/demo5\n");
        demos.append("   特点：宽松的限制，允许冲突，每周最多20节，每天最多10节\n\n");
        
        demos.append("使用方法：\n");
        demos.append("1. 获取演示配置：GET /schedule-demo/demo1\n");
        demos.append("2. 执行排课：POST /advanced-schedule/execute\n");
        demos.append("3. 查看结果：GET /quick-test/schedule-data\n");
        
        return Result.success(demos.toString());
    }
}



